package com.zhijian.medical.controller;

import com.zhijian.medical.annotation.Response;
import com.zhijian.medical.entity.po.SangerCwfxyq;
import com.zhijian.medical.entity.vo.request.*;
import com.zhijian.medical.entity.vo.response.*;
import com.zhijian.medical.service.*;
import com.zhijian.medical.util.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


/**
 * 一代测序主表 控制层
 *
 * @author HCG
 * @version 1.0
 * @date 2022-08-12 15:26:46
 */
@Slf4j
@Controller
@Api(tags = "一代测序主表")
public class SangerController {

    @Autowired
    private SangerService service;

    @Autowired
    private SangerSjpzqService sangerSjpzqService;

    @Autowired
    private SangerHszbqService sangerHszbqService;

    @Autowired
    private SangerHskzyqService sangerHskzyqService;

    @Autowired
    private SangerCwfxyqService sangerCwfxyqService;

    @Autowired
    private SangerHschyq1Service sangerHschyq1Service;

    @Autowired
    private SangerHschyq2Service sangerHschyq2Service;

    @Autowired
    private SangerHskzeqService sangerHskzeqService;

    @Autowired
    private SangerHscheqService sangerHscheqService;

    @Autowired
    private SangerCxqService sangerCxqService;

    @Autowired
    private SangerSjfxService sangerSjfxService;

    /**
     * 新增
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/sanger")
    @ApiOperation("新增")
    public boolean insert(@RequestBody SangerSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return service.insert(param) != null;
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Response
    @DeleteMapping("/sanger/{id}")
    @ApiOperation("删除")
    public boolean delete(@PathVariable("id") Long id) {
        log.info("{} - {}| delete info", this.getClass().getSimpleName(), id);
        service.deleteById(id);
        return true;
    }

    /**
     * 修改
     *
     * @param id
     * @param param
     * @return
     */
    @Response
    @PutMapping("/sanger/{id}")
    @ApiOperation("修改")
    public boolean update(@PathVariable("id") Long id, @RequestBody SangerSaveOrUpdateVo param) {
        log.info("{} - {}| update info, {}", this.getClass().getSimpleName(), id, param);
        param.setId(id);
        return service.update(param);
    }

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Response
    @GetMapping("/sanger/{id}")
    @ApiOperation("根据id查询")
    public SangerVo selectById(@PathVariable("id") Long id) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), id);
        return service.selectVoById(id);
    }

    /**
     * 分页查询
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/sanger/page")
    @ApiOperation("分页查询")
    public Page<SangerVo> selectByCondition(@RequestBody(required = false) SangerSearchVo param) {
        if (param == null)
            param = SangerSearchVo.builder().build();
        log.info("{} - {}| query info", this.getClass().getSimpleName(), param);
        return service.selectPage(param);
    }

    /**
     * 新增or修改试剂配置区数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/sanger/sjpzq")
    @ApiOperation("新增or修改试剂配置区数据")
    public boolean saveOrUpdateSangerSjpzq(@RequestBody SangerSjpzqSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return sangerSjpzqService.update(param);
    }

    /**
     * 查询试剂配制区数据
     *
     * @param sangerId
     * @return
     */
    @Response
    @GetMapping("/sanger/sjpzq/{sangerId}")
    @ApiOperation("查询试剂配制区数据")
    public SangerSjpzqVo selectSangerSjpzqBySangerId(@PathVariable("sangerId") Long sangerId) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), sangerId);
        return sangerSjpzqService.selectVoBySangerId(sangerId);
    }

    /**
     * 查询核酸制备区数据
     *
     * @param sangerId
     * @return
     */
    @Response
    @GetMapping("/sanger/hszbq/{sangerId}")
    @ApiOperation("查询核酸制备区数据")
    public SangerHszbqVo selectSangerHszbqBySangerId(@PathVariable("sangerId") Long sangerId) {
        return sangerHszbqService.selectVoBySangerId(sangerId);
    }

    /**
     * 新增or修改查询核酸制备区数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/sanger/hszbq")
    @ApiOperation("新增or修改核酸制备区数据")
    public boolean insert(@RequestBody SangerHszbqSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return sangerHszbqService.saveOrUpdate(param);
    }

    /**
     * 新增or修改核酸扩增一区数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/sanger/hskzyq")
    @ApiOperation("新增or修改核酸扩增一区数据")
    public boolean saveOrUpdateSangerHskzyq(@RequestBody SangerHskzyqSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return sangerHskzyqService.saveOrUpdate(param);
    }

    /**
     * 查询核酸扩增一区数据
     *
     * @return
     */
    @Response
    @GetMapping("/sanger/hskzyq/{sangerId}")
    @ApiOperation("查询核酸扩增一区数据")
    public SangerHskzyqVo selectSangerHskzyqBySangerId(@PathVariable("sangerId") Long sangerId) {
        return sangerHskzyqService.selectVoBySangerId(sangerId);
    }

    /**
     * 新增or修改产物分析一区数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/sanger/cwfxyq")
    @ApiOperation("新增or修改产物分析一区数据")
    public boolean saveOrUpdateSangerCwfxyq(@RequestBody SangerCwfxyq param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return sangerCwfxyqService.saveOrUpdate(param);
    }

    /**
     * 查询产物分析一区数据
     *
     * @param sangerId
     * @return
     */
    @Response
    @GetMapping("/sanger/cwfxyq/{sangerId}")
    @ApiOperation("查询产物分析一区数据")
    public SangerCwfxyqVo selectSangerCwfxyqBySangerId(@PathVariable("sangerId") Long sangerId) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), sangerId);
        return sangerCwfxyqService.selectVoBySangerId(sangerId);
    }

    /**
     * 新增or修改核酸纯化一区（普通PCR产物纯化）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/sanger/hschyq1")
    @ApiOperation("新增or修改核酸纯化一区（普通PCR产物纯化）数据")
    public boolean saveOrUpdateSangerHschyq1(@RequestBody SangerHschyq1SaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return sangerHschyq1Service.saveOrUpdate(param);
    }

    /**
     * 查询核酸纯化一区（普通PCR产物纯化）数据
     *
     * @param sangerId
     * @return
     */
    @Response
    @GetMapping("/sanger/hschyq1/{sangerId}")
    @ApiOperation("查询核酸纯化一区（普通PCR产物纯化）数据")
    public SangerHschyq1Vo selectSangerHschyq1BySangerId(@PathVariable("sangerId") Long sangerId) {
        return sangerHschyq1Service.selectVoBySangerId(sangerId);
    }

    /**
     * 新增or修改核酸纯化一区 （测序PCR试剂配制与加样）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/sanger/hschyq2")
    @ApiOperation("新增or修改核酸纯化一区 （测序PCR试剂配制与加样）数据")
    public boolean saveOrUpdateSangerHschyq2(@RequestBody SangerHschyq2SaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return sangerHschyq2Service.saveOrUpdate(param);
    }

    /**
     * 查询核酸纯化一区 （测序PCR试剂配制与加样）数据
     *
     * @param sangerId
     * @return
     */
    @Response
    @GetMapping("/sanger/hschyq2/{sangerId}")
    @ApiOperation("查询核酸纯化一区 （测序PCR试剂配制与加样）数据")
    public SangerHschyq2Vo selectSangerHschyq2BySangerId(@PathVariable("sangerId") Long sangerId) {
        return sangerHschyq2Service.selectVoBySangerId(sangerId);
    }

    /**
     * 新增or修改核酸扩增二区 （测序PCR反应）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/sanger/hskzeq")
    @ApiOperation("新增or修改核酸扩增二区 （测序PCR反应）数据")
    public boolean saveOrUpdateSangerHskzeq(@RequestBody SangerHskzeqSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return sangerHskzeqService.saveOrUpdate(param);
    }

    /**
     * 查询核酸扩增二区 （测序PCR反应）数据
     *
     * @param sangerId
     * @return
     */
    @Response
    @GetMapping("/sanger/hskzeq/{sangerId}")
    @ApiOperation("查询核酸扩增二区 （测序PCR反应）数据")
    public SangerHskzeqVo selectSangerHskzeqBySangerId(@PathVariable("sangerId") Long sangerId) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), sangerId);
        return sangerHskzeqService.selectVoBySangerId(sangerId);
    }

    /**
     * 新增or修改核酸纯化二区 （测序PCR产物纯化）、核酸扩增二区（变性）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/sanger/hscheq")
    @ApiOperation("新增or修改核酸纯化二区 （测序PCR产物纯化）、核酸扩增二区（变性）数据")
    public boolean saveOrUpdateSangerHscheq(@RequestBody SangerHscheqSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return sangerHscheqService.saveOrUpdate(param);
    }

    /**
     * 查询核酸纯化二区 （测序PCR产物纯化）、核酸扩增二区（变性）数据
     *
     * @param sangerId
     * @return
     */
    @Response
    @GetMapping("/sanger/hscheq/{sangerId}")
    @ApiOperation("查询核酸纯化二区 （测序PCR产物纯化）、核酸扩增二区（变性）数据")
    public SangerHscheqVo selectSangerHscheqBySangerId(@PathVariable("sangerId") Long sangerId) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), sangerId);
        return sangerHscheqService.selectVoBySangerId(sangerId);
    }

    /**
     * 新增or修改测序区（毛细管电泳）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/sanger/cxq")
    @ApiOperation("新增or修改测序区（毛细管电泳）数据")
    public boolean saveOrUpdateSangerCxq(@RequestBody SangerCxqSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return sangerCxqService.saveOrUpdate(param);
    }

    /**
     * 查询测序区（毛细管电泳）数据
     *
     * @param sangerId
     * @return
     */
    @Response
    @GetMapping("/sanger/cxq/{sangerId}")
    @ApiOperation("查询测序区（毛细管电泳）数据")
    public SangerCxqVo selectSangerCxqBySangerId(@PathVariable("sangerId") Long sangerId) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), sangerId);
        return sangerCxqService.selectVoBySangerId(sangerId);
    }

    /**
     * 新增or修改查询数据分析（测序区、分子诊断室）数据
     *
     * @param param
     * @return
     */
    @Response
    @PostMapping("/sanger/sjfx")
    @ApiOperation("新增or修改查询数据分析（测序区、分子诊断室）数据")
    public boolean saveOrUpdateSangerSjfx(@RequestBody SangerSjfxSaveOrUpdateVo param) {
        log.info("{} - {}| insert info", this.getClass().getSimpleName(), param);
        return sangerSjfxService.saveOrUpdate(param);
    }

    /**
     * 查询数据分析（测序区、分子诊断室）数据
     *
     * @param sangerId
     * @return
     */
    @Response
    @GetMapping("/sanger/sjfx/{sangerId}")
    @ApiOperation("查询数据分析（测序区、分子诊断室）数据")
    public SangerSjfxVo selectSangerSjfxBySangerId(@PathVariable("sangerId") Long sangerId) {
        log.info("{} - {}| query info", this.getClass().getSimpleName(), sangerId);
        return sangerSjfxService.selectVoBySangerId(sangerId);
    }

}